<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>查看事件</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<link href="<?php echo base_url()?>media/css/style.css" type="text/css" rel="stylesheet"/>
<link href="<?php echo base_url()?>media/css/jquery-ui-1.8.6.custom.css" type="text/css" rel="stylesheet"/>
<script type="text/javascript" src="<?php echo base_url()?>media/js/jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>media/js/jquery/jquery-ui-1.8.6.custom.min.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>media/js/jquery/jquery.validate.min.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>media/js/swfupload/swfupload.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>media/js/swfupload/swfupload.queue.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>media/js/swfupload/fileprogress.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>media/js/swfupload/handlers.js"></script>
<script type="text/javascript" src="<?php echo base_url()?>media/js/check/CheckViewAgentForm.js"></script>
<style>
</style>
</head>
<body>
<div class="form_div" >
	<h5>SJ<?=sprintf("%08d", $eventId)?>: <?=htmlspecialchars($event['event_title'])?></h5>
	<form action="<?=base_url()?>innerUser" method="post" id="modifyRequestByAgent" onclick="return false;">
		<div class="form_block black_border margin_t_b_5">
			<div class="input_item input_item_width140 margin_r_160">
				<label>用户名</label>
				<input type="text" style="width:120px;" name="event_owner" readonly="true" value="<?php if ($owner_info) {echo $owner_info['realname'];}?>" readonly="readonly" />
			</div>
			<div class="select_item">
				<label>用户类型</label>
				<select name="event_usertype" readonly="true">
					<?php foreach($event_usertype_list as $row):?>
                    <option value="<?php echo $row['option_id'];?>" <?php if($row['option_id']==$event['event_usertype']){echo "selected";}?>><?php echo $row['option_name'];?></option>
                    <?php endforeach;?>
				</select>
			</div>
			<div class="input_item input_item_width140 margin_r_160">
				<label>公司部门</label>
				<input type="text"  name="department" readonly="true" value="<?php if ($owner_info) {echo $owner_info['department'];}?>"/>
			</div>
			<div class="input_item" style="width:250px">
				<label>联系电话</label>
				<input type="text" name="phone1" readonly="true" style="width:30px;"/>
				<input type="text" name="phone2" readonly="true"/> -
				<input type="text" name="phone3" style="width:30px;" readonly="true"/>
			</div>
			<div class="input_item input_item_width140 margin_r_160">
				<label>邮件地址</label>
				<input type="text" name="email" readonly="true" value="<?php if ($owner_info) {echo $owner_info['email'];}?>"/>
			</div>
			<div class="input_item input_item_width140">
				<label>手机</label>
				<input type="text" name="mobile" readonly="true"/>
			</div>
			<div class="input_item input_item_width500">
				<label>地址</label>
				<input type="text" name="address" readonly="true"/>
			</div>
		<div class="clear_both"></div>
		</div>
		<div class="form_block black_border margin_t_b_5">
			<div class="input_item">
				<label>事件号</label>
				<input type="text" name="event_id" style="width:120px;" value="SJ<?php printf("%08d", $eventId);?>" readonly/>
			</div>
			<div class="select_item">
				<label>请求类型</label>
				<select name="event_type" readonly="true">
					<?php foreach($event_type_list as $row):?>
                    <option value="<?php echo $row['option_id'];?>" <?php if($row['option_id']==$event['event_type']){echo "selected";}?>><?php echo $row['option_name'];?></option>
                    <?php endforeach;?>
				</select>
			</div>
			<div class="select_item">
				<label>状态</label>
				<select name="event_status" readonly="true">
					<?php foreach($event_status_list as $row):?>
                    <option value="<?php echo $row['option_id'];?>" <?php if($row['option_id']==$event['event_status']){echo "selected";}?>><?php echo $row['option_name'];?></option>
                    <?php endforeach;?>
				</select>
			</div>
			<div class="select_item">
				<label>紧急程度</label>
				<select name="event_emergency" readonly="true">
					<?php foreach($event_emergency_list  as $code=>$name):?>
                    <option value="<?php echo $code;?>" <?php if($code==$event['event_emergency']){echo "selected";}?>><?php echo $name;?></option>
                    <?php endforeach;?>
				</select>
			</div>
			<div class="select_item">
				<label>影响范围</label>
				<select name="event_influencearea" readonly="true">
					<?php foreach($event_influencearea_list as $row):?>
                    <option value="<?php echo $row['option_id'];?>" <?php if($row['option_id']==$event['event_influencearea']){echo "selected";}?>><?php echo $row['option_name'];?></option>
                    <?php endforeach;?>
				</select>
			</div>
			<div class="select_item">
				<label>优先级</label>
				<select name="event_priority" readonly="true">
					<?php foreach($event_pri_list  as $code=>$name):?>
                    <option value="<?php echo $code;?>" <?php if($code==$event['event_priority']){echo "selected";}?>><?php echo $name;?></option>
                    <?php endforeach;?>
				</select>
			</div>
			<div class="input_item margin_r_218">
				<label>影响开始时间</label>
				<input type="text" name="event_begintime" style="width:120px" value="<?=$event['event_begintime']?>" readonly="readonly" />
			</div>
			<div class="select_item">
				<label>来源</label>
				<select name="event_source" readonly="true">
					<?php foreach($event_source_list as $row):?>
                    <option value="<?php echo $row['option_id'];?>" <?php if($row['option_id']==$event['event_source']){echo "selected";}?>><?php echo $row['option_name'];?></option>
                    <?php endforeach;?>
				</select>
			</div>
					<div class="select_item margin_r_218">
						<label>类别</label>
						<select name="event_category" readonly="true">
							<?php foreach($event_cat_list as $row):?>
                            <option value="<?php echo $row['option_id'];?>" <?php if($row['option_id']==$event['event_category']){echo "selected";}?>><?php echo $row['option_name'];?></option>
                            <?php endforeach;?>
						</select>
					</div>
					<div class="select_item">
						<label>子类</label>
						<select name="event_subclass" readonly="true">
							<?php foreach($event_subclass as $row): ?>
                            <option value="<?=$row['option_id']?>" <?php if($row['option_id']==$event['event_subclass']){echo "selected";}?>><?=$row['option_name']?></option>
                            <?php endforeach; ?>
						</select>
					</div>
			<div class="input_item input_item_width500" >
				<label>主题</label>
				<input type="text" name="event_title" value="<?php echo htmlspecialchars($event['event_title']);?>" readonly="readonly" />
			</div>
			<div class="textarea_item" >
				<label>描述</label>
				<textarea name="event_desc" readonly="readonly"><?php echo htmlspecialchars($event['event_desc']);?></textarea>
			</div>
				<div id="old_uploaded_file_info" class="uploaded_file_info" style="padding-left:80px;clear:both;">
		            <?php foreach($event_attachments as $row): ?>
		            <?php if($row['attachment_isreply']==2): ?>
		            <div class="file_info"><a href="<?php echo base_url().$row['attachment_path'];?>"><?php echo $row['attachment_name'];?></a></div>
		           <?php endif;?>
		            <?php endforeach; ?>
				</div>
			<div class="clear_both"></div>
			<div class="input_item input_item_width300">
				<label>影响业务</label>
				<input type="text"  name="event_influencebusiness" value="<?php echo htmlspecialchars($event['event_influencebusiness']);?>" readonly="readonly" />
			</div>
			<div class="clear_both"></div>
		</div>
	<div class="form_block black_border margin_t_b_5">
		<div class="textarea_item" >
			<label>解决办法</label>
			<textarea name="event_workrecord" readonly><?php if(!empty($event['event_solution'])): echo $event['event_solution']; else:?>事件处理中,暂未提供解决方案<?php endif;?></textarea>
		</div>
		<div class="clear_both"></div>
		<div id="uploaded_file_info2"  class="uploaded_file_info" style="padding-left:80px;clear:both;">
				<?php if (count($event_attachments)>0 && ($event['event_status'] == events_config::$event_status['EVENT_STATUS_SOLUTION'] || $event['event_status'] == events_config::$event_status['EVENT_STATUS_CLOSE'])): ?>
	            <?php foreach($event_attachments as $row): ?>
				<?php if($row['attachment_isreply']==1): ?>
	            <div class="file_info"><a href="<?php echo base_url().$row['attachment_path'];?>"><?php echo $row['attachment_name'];?></a><!--span class='del_attach' aid='<?php echo $row['attachment_id'];?>'>X</span--></div>
				<?php endif; ?>
	            <?php endforeach; ?>
				<?php endif; ?>
		</div>
		<div class="clear_both"></div>
	</div>
<?php if ($event['event_status'] != events_config::$event_status['EVENT_STATUS_CLOSE']):?>
	<div class="form_block black_border margin_t_b_5" style="text-align:center">
	<?php if ($event['event_status'] == events_config::$event_status['EVENT_STATUS_SOLUTION']):?>
		<input type=button  id="open_again" class="sub_btn" value="重新打开" />
	<?php endif; ?>
		<input type=button  id="close_btn" class="sub_btn" value="确认关闭" />
	<?php if ($event['event_status'] == events_config::$event_status['EVENT_STATUS_CREATE']):?>
		<input type=button id="append_desc" class="sub_btn" value="追加描述" />
	<?php endif; ?>
	</div>
<?php endif;?>

		<div class="form_block black_border margin_t_b_5" id="append_desc_txt" style="display:none;">
			<div class="textarea_item">
				<label>描述/理由</label>
				<textarea name="append_desc"></textarea>
			</div>
			<div class="clear_both"></div>
			<div id="uploaded_file_info"  class="uploaded_file_info" style="padding-left:80px;clear:both;">
	            <div id="fsUploadProgress"></div>
			</div>
			<div class="clear_both"></div>
			<div class="upload_item">
				<label>附件</label>
				<span id="upload_btn"> </span> <input id="btnCancel" type="button" value="cancel" style="display:none;" />
			</div>
			<div class="clear_both"></div>
			<div style="text-align:center">
				<input type="submit" class="sub_btn" id="appendDescBtn" value="提交" />
			</div>
		</div>
	</form>
</div>
<div id="closeBox" style="display:none"></div>
</body>
</html>
<script>
var swfu;
var swfu2;
var settings = {
		flash_url : "<?=base_url()?>media/flash/swfupload.swf",
		upload_url: "<?=base_url()?>upload/uploadAttachment/eventId/<?php echo $eventId;?>",
		post_params: {"PHPSESSID" : "<?php echo session_id(); ?>"},
		custom_settings : {
			progressTarget : "fsUploadProgress",
			cancelButtonId : "btnCancel",
			base_url:"<?=base_url()?>",
			uploadedFileInfoDiv:"uploaded_file_info"
		},
		debug: false,
		// Button settings
		button_image_url: "<?=base_url()?>media/images/upload_btn.gif"
	};
	swfu = new SWFUpload($.extend(settings,defaultSetting));

	//事件关闭
	var dialogOpts = {
			modal: false,
			bgiframe: false,
			autoOpen: false,
			height: 230,
			width: 300,
			draggable: true,
			resizeable: true,
			title: '关闭事件',
			open: function() {
				$("#closeBox").load("<?php echo base_url()?>innerUser/loadCloseForm",{id:"<?=$eventId?>"});
			},
			close: function() {
				$("#closeBox").dialog("destroy");
			}
		};
	$("#close_btn").click(function(){
		$.ajax({
			url: "<?=base_url()?>innerUser/eventDetail",
			dataType: 'json',
			type: 'post',
			data: { event_id: "<?=$eventId?>" },
			success: function(ret) {
				if (!ret.success) {
					alert(ret.msg);
					return false;
				} else if (ret.event_status == "<?=events_config::$event_status['EVENT_STATUS_CLOSE']?>") {
					alert("事件已被关闭，不能重复关闭");
					return false;
				} else {
					$("#closeBox").dialog(dialogOpts);
					$("#closeBox").dialog("open");
				}
			}
		});
	});
	$("#closeEventSubmit").live('click',function(){
		var url = '<?=base_url()?>innerUser/close_event/event_id/<?=$eventId?>/';
		$.ajax({
			data: { event_closereason: $("#close_reason").val() },
			dataType: 'json',
			url: url,
			type: 'post',
			success: function(ret) {
				alert(ret.msg);
				if (ret.success) {
					$("#closeBox").dialog("close");
				} else {
					alert(ret.msg);
				}
			}
		});
	});

	$("#closeEventCancel").live('click',function(){
		$("#closeBox").dialog("close");
	});

	$("#append_desc").click(function() {
		$.ajax({
			url: "<?=base_url()?>innerUser/eventDetail",
			dataType: 'json',
			type: 'post',
			data: { event_id: "<?=$eventId?>" },
			success: function(ret) {
				if (!ret.success) {
					alert(ret.msg);
					return false;
				} else if (ret.event_status == "<?=events_config::$event_status['EVENT_STATUS_CLOSE']?>") {
					alert("事件已被关闭，不能再追加描述");
					return false;
				} else {
					$("textarea[name=append_desc]").val('');
					$("#append_desc_txt").toggle("display:block;");
				}
			}
		});
	});

	//重新打开
	$("#open_again").click(function(){
		var eventId	= <?php echo $eventId;?>;
		var url	= "<?=base_url()?>innerUser/openagain";
		$.ajax({
			url: url,
			dataType: 'json',
			type: 'post',
			data: {eventId: eventId},
			success: function(ret) {
				alert(ret.msg);
				if (ret.status)
					window.location.href = window.location.href;
			}
		})
	});
		$(".del_attach").live('click',function(){
			var divObj = $(this);
			$.get('<?php echo base_url()?>upload/delAttachment/aid/'+divObj.attr('aid'),function(data){
				if(data=='success')
				{
					divObj.parent().fadeOut();
				}
			});
		});

	//提交追加描述
	$("#appendDescBtn").click(function(){
		var appendDesc = $("textarea[name=append_desc]").val();
		var url = "<?php echo base_url()?>innerUser/appendDesc";
		$.ajax({
			url: url,
			dataType:'json',
			data: { appendDesc:appendDesc,eventId:<?php echo intval($eventId)?>, s:Math.random() },
			type: 'post',
			success: function(ret) {
				if(ret.status)
				{
						window.location.href = window.location.href;
						/**
						$("textarea[name=event_desc]").text($("textarea[name=event_desc]").val()+ret.content);
						$("#append_desc_txt").toggle("display:block;");
						$("#uploaded_file_info > .file_info").children(".del_attach").remove();
						$("#old_uploaded_file_info").append($("#uploaded_file_info").children(".file_info"));
						$("#uploaded_file_info").children(".file_info").remove();
						**/
				} else {
					alert(ret.msg);
				}
			}
		});
		return false;
	});
</script>
